Skip to content

[qtbase] Fix qt.toolchain.cmake corruption for Emscripten builds#49429

Merged
JavierMatosD merged 2 commits intomicrosoft:masterfrom
boardend:fix-qtbase-toolchain-emscripten
Mar 3, 2026
Merged

[qtbase] Fix qt.toolchain.cmake corruption for Emscripten builds#49429
JavierMatosD merged 2 commits intomicrosoft:masterfrom
boardend:fix-qtbase-toolchain-emscripten

Conversation

@boardend
Copy link
Contributor

@boardend boardend commented Jan 14, 2026

The regex replacement for __qt_chainload_toolchain_file was malformed, causing a literal \n to be written instead of an actual newline. This broke toolchain chaining for Emscripten/WebAssembly builds where vcpkg chainloads Qt's toolchain.

Follow up on #46314

Observed with 2025.12.12, fixes the resulting corrupted line (tested on e70ab1d , Qt 6.10.0):

  set(__qt_chainload_toolchain_file "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}\n")

Checklist

  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version.
  • Any fixed CI baseline entries are removed from that file.
  • Any patches that are no longer applied are deleted from the port's directory.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is added to each modified port's versions file.

@boardend
Copy link
Contributor Author

@m-kuhn and @dg0yt would be thankful if one of you could confirm this is an issue. At least it fixed the problem for me.

@m-kuhn
Copy link
Contributor

m-kuhn commented Jan 16, 2026

I can't confirm this is an issue (I was able to build using emscripten recently, I'm not sure what I'd need to change to trigger this behavior), but the \n in the quotes of the original version looks very suspicious.

This is what we get iiuc, but it's unlikely to be what we want:

set(__qt_chainload_toolchain_file "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}
")

@dg0yt
Copy link
Contributor

dg0yt commented Jan 19, 2026

set(__qt_chainload_toolchain_file "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}
")

This is also what I see for x64-linux native. Ugly, but not broken. Emscripten should be no different.

@boardend
Copy link
Contributor Author

Thanks for the feedback

@dg0yt just tested again with emsdk 4.0.22 / CMake 3.30.4:

Error: CMake Error at build/vcpkg/packages/qtbase_wasm32-emscripten-qt-threads/share/Qt6/qt.toolchain.cmake:36:
  Parse error.  Expected a newline, got identifier with text "endif".
Call Stack (most recent call first):
  CMakeLists.txt:51 (include)
Screenshot from 2026-01-19 10-31-53

So the fix is definitely needed...

But I can confirm that your suggestion works and will just accept it.

@boardend boardend marked this pull request as ready for review January 19, 2026 12:58
@dg0yt
Copy link
Contributor

dg0yt commented Jan 20, 2026

Ugly, but not broken. Emscripten should be no different.

🤦 Of course broken, with a line break in a real filepath, as soon as __qt_chainload_toolchain_file is actually used.

Copy link
Contributor

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder: Before commit/push, you need to increment port-version in ports/qtbase/vcpkg.json, and the run vcpkg x-add-version qtbase.

@vicroms vicroms marked this pull request as draft January 24, 2026 08:20
@boardend boardend force-pushed the fix-qtbase-toolchain-emscripten branch from 5d9455a to 9953b6e Compare February 27, 2026 13:18
The regex replacement for __qt_chainload_toolchain_file placed the
newline inside the closing quote instead of after the closing paren,
causing a literal line break in the filepath. This broke toolchain
chaining for Emscripten/WebAssembly builds where vcpkg chainloads
Qt's toolchain.

Follow up on microsoft#46314
@boardend boardend force-pushed the fix-qtbase-toolchain-emscripten branch from 9953b6e to 660013d Compare February 27, 2026 13:19
@boardend
Copy link
Contributor Author

@microsoft-github-policy-service agree company="OPENGIS.ch"

@boardend
Copy link
Contributor Author

Tested again with ffc071e

@boardend boardend marked this pull request as ready for review February 28, 2026 16:04
@JavierMatosD
Copy link
Contributor

I'm seeing there are two PRs that are touching qtbase -> #49191. I'm asking the contributor if they would like to absorb this change.

@JavierMatosD JavierMatosD marked this pull request as draft March 2, 2026 16:01
@JavierMatosD JavierMatosD marked this pull request as ready for review March 2, 2026 21:37
@JavierMatosD JavierMatosD merged commit cae8f58 into microsoft:master Mar 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants